<?php

namespace app\system\controller;

use app\system\model\DictDataModel;
use think\App;

/**
 * 数据字典信息
 *
 * @author xuxiwang
 */
class DictData extends Base
{
    private $dictDataModel;

    public function __construct(App $app)
    {
        parent::__construct($app);
        $this->dictDataModel = new DictDataModel();
    }

    public function list()
    {
        $param = $this->request->param();

        $info = $this->dictDataModel
            ->where('dict_type', '=', $param['dictType'])
            ->paginate([
            'page'=>$param['pageNum'],
            'list_row'=>$param['pageSize']
        ])->toArray();

        $returnData = [
            'code'=> 200,
            'msg'=> '操作成功',
            'rows'=> $info['data'],
            'total'=> $info['total']
        ];
        return json($returnData);

    }



    public function export()
    {

    }

    /**
     * 查询字典数据详细
     */
    public function getInfo()
    {

    }

    /**
     * 根据字典类型查询字典数据信息
     */

    public function dictType()
    {
        $param = $this->request->param();
        //where status = '0' and dict_type = #{dictType} order by dict_sort asc
        $dataList = $this->dictDataModel
            ->where('status', '=', '0')
            ->where('dict_type', '=', $param['dictType'])
            ->order('dict_sort asc')
            ->select()
            ->toArray();

        $returnData = [
            'code'=> 200,
            'msg'=> '操作成功',
            'data'=> $dataList
        ];
        return json($returnData);
    }

    /**
     * 新增字典类型
     */
    public function add()
    {

    }

    /**
     * 修改保存字典类型
     */
    public function edit()
    {

    }

    /**
     * 删除字典类型
     */

    public function remove()
    {

    }
}